'''
Author: fisher luthor-li@qq.com
Date: 2024-04-29 10:41:10
LastEditors: fisher luthor-li@qq.com
LastEditTime: 2024-04-29 10:41:16
FilePath: \projects\fan.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
from machine import Pin, PWM
from time import sleep

FANS = 19
i = 0
pwm = PWM(Pin(FANS))
pwm.freq(1000)  # 设置1kHz的频率


def run():
    global i
    while i < 250:
        i += 50
        pwm.duty(i)
        sleep(2)
    sleep(2)
    while i > 0:
        i -= 50
        pwm.duty(i)
        sleep(2)


def setup():
    pwm.init(duty=0)
    print("fans test begin!!!")


def main():
    setup()
    while True:
        run()


if __name__ == "__main__":
    main()
